<template>
  <div>
    <BasicTable @register="registerTable" :rowSelection="rowSelection">
      <template #action="{ record }">
        <TableAction :actions="getActions(record)" />
      </template>
    </BasicTable>
  </div>
</template>
<script lang="ts" name="retain-list" setup>
  import { BasicTable, TableAction } from '/@/components/Table';
  //   import { list, deleteRetain } from './retain.api';
  import { columns, searchFormSchema } from './retain.data';
  import { useListPage } from '/@/hooks/system/useListPage';

  // 列表页面公共参数、方法
  const { tableContext } = useListPage({
    tableProps: {
      title: '保留消息',
      //   api: list,
      columns: columns,
      showIndexColumn: true,
      formConfig: {
        schemas: searchFormSchema,
      },
    },
  });

  const [registerTable, { reload }] = tableContext;

  /**
   * 操作列定义
   * @param record
   */
  function getActions(record) {
    return [
      {
        label: '删除',
        popConfirm: {
          title: '是否确认删除',
          confirm: handleDelete.bind(null, record),
        },
      },
    ];
  }
  /**
   * 删除事件
   */
  async function handleDelete(record) {
    await deleteRetain({ id: record.id }, reload);
  }
</script>
